/**
 * @file debug.h
 *
 * @copyright This file creat by rensuiyi ,all right reserve!
 *
 * @author rensuyi
 *
 * @date 2013/12/21 11:37:49
 */
#ifndef __SL_DEBUG_H__
#define __SL_DEBUG_H__

#ifdef __cplusplus
extern "C"
{
#endif /*__cplusplus */

#include "includes.h"
// The definition of the debug level
#define  DEBUG_NONE          (15)
#define  DEBUG_USER          (14)
#define  DEBUG_FAULT         (13)
#define  DEBUG_ERROR         (12)
#define  DEBUG_WARN          (11)
#define  DEBUG_MESSAGE       (10)
#define  DEBUG_INFO          (9)
#define  DEBUG_ALL           (1)

typedef int (* debug_stream_t)(const char* buf, int len);

extern int debug_init(debug_stream_t stream, uint8_t level);
extern uint8_t debug_set_level(uint8_t level);
extern uint8_t debug_get_level(uint8_t level);
extern debug_stream_t debug_set_stream(debug_stream_t stream);
extern debug_stream_t debug_get_stream(void);
extern void debug(uint8_t level, char* fmt, ...);  //!< __attribute__((format (printf, 2, 3)));

#define  debug_user(fmt,args...)      debug(DEBUG_USER,fmt,##args)
#define  debug_info(fmt,args...)      debug(DEBUG_INFO,"[INFO]"fmt,##args)
#define  debug_message(fmt,args...)   debug(DEBUG_MESSAGE,"[MESSAGE]"fmt,##args)
#define  debug_warn(fmt,args...)      debug(DEBUG_WARN,"[WARN]"fmt,##args)
#define  debug_error(fmt,args...)     debug(DEBUG_ERROR,"[ERROR]"fmt,##args)

#ifdef __cplusplus
}
#endif /*__cplusplus */
#endif /* __SL_DEBUG_H__ */
